﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Text;

using XianShang.Data;
using XianShang.Common;
using XianShang.Entity;
using XianShang.Data.DataProvider;

namespace XianShang.Data.DataProvider
{
    public class RolesPermissions
    {
        /// <summary>
        /// 根據用戶名和模塊代號取得用戶模塊權限
        /// </summary>
        /// <param name="Account"></param>
        /// <param name="ModuleCode"></param>
        /// <returns></returns>
        public static DataSet GetModulePermissions(string Account, int ModuleCode)
        {
            return DatabaseProvider.GetInstance().GetModulePermissions(Account,ModuleCode);
        }
        /// <summary>
        /// 根據用戶名和模塊代號取得用戶模塊權限
        /// </summary>
        /// <param name="Account"></param>
        /// <param name="ModuleName"></param>
        /// <returns></returns>
        public static DataSet GetModulePermissions(string Account, string ModuleName)
        {
            return DatabaseProvider.GetInstance().GetModulePermissions(Account, ModuleName);
        }
        /// <summary>
        /// 根據帳號取得所有模塊角色權限
        /// </summary>
        /// <param name="Account">帳號</param>
        /// <returns></returns>
        public static DataSet GetAllModulePermissions(string Account)
        {
            return DatabaseProvider.GetInstance().GetAllModulePermissions(Account);
        }
        /// <summary>
        /// 根據用戶名取得該用戶隸屬角色
        /// </summary>
        /// <param name="Account"></param>
        /// <returns></returns>
        public static DataSet GetAllUserRoles(string Account)
        {
            return DatabaseProvider.GetInstance().GetAllUserRoles(Account);
        }
        /// <summary>
        /// 根據用戶名取得該用戶擁有操作模塊資源
        /// </summary>
        /// <param name="Account"></param>
        /// <returns></returns>
        public static DataSet GetAllUserModule(string Account)
        {
            return DatabaseProvider.GetInstance().GetAllUserModule(Account);
        }
        /// <summary>
        /// 取得所有模塊資源
        /// </summary>
        /// <returns></returns>
        public static DataSet GetAllModule()
        {
            return DatabaseProvider.GetInstance().GetAllModule();
        }
        /// <summary>
        /// 創建一個新角色
        /// </summary>
        /// <param name="RolesName">角色名</param>
        /// <returns></returns>
        public static int AddNewRoles(string RolesName)
        {
            return DatabaseProvider.GetInstance().AddNewRoles(RolesName);
        }
        /// <summary>
        /// 創建一個新角色并返回角色ID
        /// </summary>
        /// <param name="RolesName">角色名</param>
        /// <returns></returns>
        public static object AddNewRolesReturnId(string RolesName)
        {
            return DatabaseProvider.GetInstance().AddNewRolesReturnId(RolesName);
        }
        /// <summary>
        /// 添加（分配）用戶角色
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="RolesId"></param>
        /// <returns></returns>
        public static int AddNewUserRoles(int UserId, int RolesId)
        {
            return DatabaseProvider.GetInstance().AddNewUserRoles(UserId,RolesId);
        }
        /// <summary>
        /// 添加（分配）用戶角色
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="RolesId"></param>
        /// <returns></returns>
        public static int AddNewUserRoles(string UserId, string RolesId)
        {
            return DatabaseProvider.GetInstance().AddNewUserRoles(UserId,RolesId);
        }
        /// <summary>
        /// 根據用戶名取得用戶主鍵ID
        /// </summary>
        /// <param name="UserName"></param>
        /// <returns></returns>
        public static object GetUserID(string UserName)
        {
            return DatabaseProvider.GetInstance().GetUserID(UserName);
        }
        /// <summary>
        /// 根據角色名取得角色主鍵ID
        /// </summary>
        /// <param name="RolesName"></param>
        /// <returns></returns>
        public static object GetRolesID(string RolesName)
        {
            return DatabaseProvider.GetInstance().GetRolesID(RolesName);
        }
        /// <summary>
        /// 取得角色表所有信息
        /// </summary>
        /// <returns></returns>
        public static DataSet GetRolesInfo()
        {
            return DatabaseProvider.GetInstance().GetRolesInfo();
        }
        /// <summary>
        /// 取得權限類表全部記錄信息
        /// </summary>
        /// <returns></returns>
        public static DataSet GetPermissionsInfo()
        {
            return DatabaseProvider.GetInstance().GetPermissionsInfo();
        }
         /// <summary>
        /// 取得所有模塊與角色與權限信息
        /// </summary>
        /// <returns></returns>
        public static DataSet GetAllRolesModulePermissions()
        {
            return DatabaseProvider.GetInstance().GetAllRolesModulePermissions();
        }
        /// <summary>
        /// 取得角色模塊資源
        /// </summary>
        /// <param name="rolesid"></param>
        /// <returns></returns>
        public static DataSet GetRolesModule(string rolesid)
        {
            return DatabaseProvider.GetInstance().GetRolesModule(rolesid);
        }
        /// <summary>
        /// 添加一組操作權限
        /// </summary>
        /// <param name="Read"></param>
        /// <param name="Edit"></param>
        /// <param name="Delete"></param>
        /// <param name="Add"></param>
        /// <returns></returns>
        public static int AddNewPermissions(PermissionsInfo Per)
        {
            return DatabaseProvider.GetInstance().AddNewPermissions(Per);
        }
        /// <summary>
        /// 添加（分配）角色權限
        /// </summary>
        /// <param name="RolesId"></param>
        /// <param name="PermissionsId"></param>
        /// <returns></returns>
        public static int AddNewRolesPermissions(int RolesId, int PermissionsId)
        {
            return DatabaseProvider.GetInstance().AddNewRolesPermissions(RolesId,PermissionsId);
        }
        /// <summary>
        /// 根據角色主鍵ID刪除角色
        /// </summary>
        /// <param name="RolesId"></param>
        /// <returns></returns>
        public static int DeleteRoles(int RolesId)
        {
            return DatabaseProvider.GetInstance().DeleteRoles(RolesId);
        }
        /// <summary>
        /// 根據角色名刪除角色
        /// </summary>
        /// <param name="RolesName"></param>
        /// <returns></returns>
        public static int DeleteRoles(string RolesName)
        {
            return DatabaseProvider.GetInstance().DeleteRoles(RolesName);
        }
        /// <summary>
        /// 根據UserRoles主鍵ID刪除用戶角色
        /// </summary>
        /// <param name="UserRolesId"></param>
        /// <returns></returns>
        public static int DeleteUserRoles(int UserRolesId)
        {
            return DatabaseProvider.GetInstance().DeleteUserRoles(UserRolesId);
        }
        /// <summary>
        /// 刪除用戶角色
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="RolesId"></param>
        /// <returns></returns>
        public static int DeleteUserRoles(int UserId, int RolesId)
        {
            return DatabaseProvider.GetInstance().DeleteUserRoles(UserId,RolesId);
        }
        /// <summary>
        /// 根據指定用戶ID刪除用戶角色
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="RolesId"></param>
        /// <returns></returns>
        public static int DeleteUserRoles(string UserId)
        {
            return DatabaseProvider.GetInstance().DeleteUserRoles(UserId);
        }
        /// <summary>
        /// 根據權限主鍵ID刪除權限組
        /// </summary>
        /// <param name="PermissionsId"></param>
        /// <returns></returns>
        public static int DeletePermissions(int PermissionsId)
        {
            return DatabaseProvider.GetInstance().DeletePermissions(PermissionsId);
        }
        /// <summary>
        /// 刪除角色權限
        /// </summary>
        /// <param name="RolesId"></param>
        /// <param name="PermissionsId"></param>
        /// <returns></returns>
        public static int DeleteRolesPermissions(int RolesId, int PermissionsId)
        { 
            return DatabaseProvider.GetInstance().DeleteRolesPermissions(RolesId,PermissionsId);
        }
        /// <summary>
        /// 根據RolesPermissions主鍵ID刪除角色權限
        /// </summary>
        /// <param name="RolesPermissionsId"></param>
        /// <returns></returns>
        public static int DeleteRolesPermissions(int RolesPermissionsId)
        {
            return DatabaseProvider.GetInstance().DeleteRolesPermissions(RolesPermissionsId);
        }
        /// <summary>
        /// 根據ROLES表組件ID更改角色名
        /// </summary>
        /// <param name="RolesId"></param>
        /// <param name="RolesName"></param>
        /// <returns></returns>
        public static int UpdateRolesName(int RolesId, string RolesName)
        {
            return DatabaseProvider.GetInstance().UpdateRolesName(RolesId, RolesName);
        }
        /// <summary>
        /// 添加新操作模塊
        /// </summary>
        /// <param name="MInfo"></param>
        /// <returns></returns>
        public static int AddNewModule(ModuleInfo MInfo)
        {
            return DatabaseProvider.GetInstance().AddNewModule(MInfo);
        }
        /// <summary>
        /// 根據模塊ID更新模塊名
        /// </summary>
        /// <param name="MInfo"></param>
        /// <returns></returns>
        public static int UpdateModuleName(ModuleInfo MInfo)
        {
            return DatabaseProvider.GetInstance().UpdateModuleName(MInfo);
        }
        /// <summary>
        /// 根據模塊ID刪除模塊
        /// </summary>
        /// <param name="MInfo"></param>
        /// <returns></returns>
        public static int DeleteModuleById(ModuleInfo MInfo)
        {
            return DatabaseProvider.GetInstance().DeleteModuleById(MInfo);
        }
        /// <summary>
        /// 根據模塊名刪除模塊
        /// </summary>
        /// <param name="MInfo"></param>
        /// <returns></returns>
        public static int DeleteModuleByName(ModuleInfo MInfo)
        {
            return DatabaseProvider.GetInstance().DeleteModuleByName(MInfo);
        }
        /// <summary>
        /// 給角色指定（添加）操作模塊
        /// </summary>
        /// <param name="RMinfo"></param>
        /// <returns></returns>
        public static int AddNewRolesModule(RolesModuleInfo RMinfo)
        {
            return DatabaseProvider.GetInstance().AddNewRolesModule(RMinfo);
        }
        /// <summary>
        /// 根據主鍵ID刪除角色操作模塊
        /// </summary>
        /// <param name="RMinfo"></param>
        /// <returns></returns>
        public static int DeleteRolesModuleById(RolesModuleInfo RMinfo)
        {
            return DatabaseProvider.GetInstance().DeleteRolesModuleById(RMinfo);
        }
        /// <summary>
        /// 根據角色ID刪除角色操作模塊
        /// </summary>
        /// <param name="RMinfo"></param>
        /// <returns></returns>
        public static int DeleteRolesModuleByRolesId(RolesModuleInfo RMinfo)
        {
            return DatabaseProvider.GetInstance().DeleteRolesModuleByRolesId(RMinfo);
        }
        /// <summary>
        /// 根據模塊ID和角色ID刪除角色操作模塊
        /// </summary>
        /// <param name="RMinfo"></param>
        /// <returns></returns>
        public static int DeleteRolesModuleByRolesIdAndModuleId(RolesModuleInfo RMinfo)
        {
            return DatabaseProvider.GetInstance().DeleteRolesModuleByRolesIdAndModuleId(RMinfo);
        }
        /// <summary>
        /// 取得所有角色信息
        /// </summary>
        /// <returns></returns>
        public static DataSet GetAllRolesInfo()
        {
            return DatabaseProvider.GetInstance().GetAllRolesInfo();
        }
        /// <summary>
        /// 根據ID刪除角色和所有關聯表數據
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static int DelRolesAndInnerTable(string id)
        {
            return DatabaseProvider.GetInstance().DelRolesAndInnerTable(id);
        }
    }
}
